package com.bw.module_service.adapter

import android.annotation.SuppressLint
import android.content.Intent
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.recyclerview.widget.RecyclerView
import com.bw.module_service.R
import com.bw.module_service.model.TaskEntity
import com.bw.module_service.ui.polling.TaskDetailsActivity
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder


class TaskAdapter(): BaseQuickAdapter<TaskEntity,BaseViewHolder>(R.layout.inspection_task_item) {

    @SuppressLint("ResourceAsColor")
    override fun convert(holder: BaseViewHolder, item: TaskEntity) {
        holder.setText(R.id.task_work, item.taskName)
        holder.setText(R.id.task_time, item.patrolTime)
        if (item.patrolStatus==1){
            holder.setText(R.id.patrolStatus, "巡检中".toString())

        }
        if (item.patrolStatus==0){
            holder.setText(R.id.patrolStatus, "未巡检".toString())

        }
        if (item.patrolStatus==2){
            holder.setText(R.id.patrolStatus, "已完成".toString())
        }
        if (item.patrolStatus==3){
            holder.setText(R.id.patrolStatus, "已作废".toString())

        }

        holder.itemView.setOnClickListener({
            //跳转到详情页
            val intent= Intent(holder.itemView.context, TaskDetailsActivity::class.java)
            intent.putExtra("task",item)
            holder.itemView.context.startActivity(intent)

        })
    }




}